package controleur;

import application.Facade;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class CommandeConnexion implements Commande {

    private String next;

    public CommandeConnexion(String next) {
        this.next = next.toLowerCase();
    }

    @Override
    public String executer(HttpServletRequest req, HttpServletResponse res) throws CommandeException {
        Facade f = new Facade();
        boolean connexionValide;

        connexionValide = f.creerCookiesIdentification(req.getParameter("username"), req.getParameter("password"), res);

        if (connexionValide) {
            return next;
        } else {
            return ConstantesWeb.PAGE_CONNEXION_INVALIDE;
        }                
    }
}
